package be.vsko.zelfevaluatie.persistence;

import java.util.ArrayList;
import java.util.List;

import be.vsko.zelfevaluatie.framework.Component;
import be.vsko.zelfevaluatie.framework.GroupKind;
import be.vsko.zelfevaluatie.framework.Section;
import be.vsko.zelfevaluatie.framework.Statement;
import be.vsko.zelfevaluatie.framework.Survey;
import be.vsko.zelfevaluatie.help.QueryParameters;

public class DbManager {
	private static DbManager singleton;
	private List<Survey> surveys;
	
	private DbManager() {initialize();}
	
	public static DbManager getDb() {
		if(singleton == null)
			singleton = new DbManager();
		return singleton;
	}
	
	private void initialize(){
		List<GroupKind> groupKinds = new ArrayList<GroupKind>();
		groupKinds.add(GroupKind.Leraar);
		List<Statement> statements = new ArrayList<Statement>();
		Statement st = new Statement("Onze schoolt geeft leerlingen een visie.", groupKinds);
		statements.add(st);
		List<Section> sections = new ArrayList<Section>();
		Section section = new Section("Leerlingen en hun Visie", statements);
		sections.add(section);
		Component l = new Component("Leerlingen", sections);
		List<Component> components = new ArrayList<Component>();
		components.add(l);
		surveys = new ArrayList<Survey>();
		Survey diso = new Survey("DISO", components);
		diso.setKey(123L);
		surveys.add(diso);
	}
	
	public List<Survey> getSurveys(QueryParameters queryParams) {		
		return surveys;
	}
	
	public Survey getSurvey(Long key) {
		for(Survey survey: surveys)
			if(survey.getKey() == key)
				return survey;
		return null;
	}
}
